package com.gadgets;

import com.gadgets.busi.GadgetsBm05Start;
import com.gadgets.busi.GadgetsBm06Start;
import com.gadgets.busi.bm03.GadgetsBm03Start;
import com.gadgets.framework.GadgetsFm04Start;
import com.gadgets.framework.common.util.ThreadTaskUtil;
import com.irm.GadgetsBm04Start;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.PropertySource;


@SpringBootApplication
@PropertySource(value = {
        "classpath:/config/spring-runningEnv.spring.properties",
        "classpath:/config/application-${gadgets.running.type}-name.properties"
})
@EnableCaching
public class GadgetsServerApplicationStart extends SpringBootServletInitializer {

    /**
     * Configure the application. Normally all you would need to do is to add sources
     * (e.g. config classes) because other settings have sensible defaults. You might
     * choose (for instance) to add default command line arguments, or set an active
     * Spring profile.
     *
     * @param builder a builder for the application context
     * @return the application builder
     * @see SpringApplicationBuilder
     */
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        ThreadTaskUtil.startThreadPool();
        return builder.sources(
                GadgetsBm08Start.class,
                GadgetsBm06Start.class,
                GadgetsBm05Start.class,
                GadgetsBm04Start.class,
                GadgetsBm03Start.class,
                GadgetsBm02Start.class,
                GadgetsFm04Start.class,
                GadgetsServerApplicationStart.class,
                GadgetsEurekaClientStart.class
        );
    }

    public static void main(String[] args) {
        SpringApplication.run(new Class[]{
                GadgetsBm08Start.class,
                GadgetsBm06Start.class,
                GadgetsBm05Start.class,
                GadgetsBm04Start.class,
                GadgetsBm03Start.class,
                GadgetsBm02Start.class,
                GadgetsFm04Start.class,
                GadgetsServerApplicationStart.class,
                GadgetsEurekaClientStart.class
        },args);
    }

}
